package com.yq.cp.service.data.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yq.cp.entity.basics.EquipmentManagement;
import com.yq.cp.entity.basics.OrganizationalStructure;
import com.yq.cp.entity.common.PageVo;
import com.yq.cp.entity.data.CoefficientYear;
import com.yq.cp.entity.data.NengKongDataDay;
import com.yq.cp.entity.data.VideoSurveillance;
import com.yq.cp.entity.data.dto.NyzfdqkDto;
import com.yq.cp.entity.data.vo.IndexGfVo;
import com.yq.cp.entity.manage.OpsTicketsMessage;
import com.yq.cp.mapper.basics.EquipmentManagementMapper;
import com.yq.cp.mapper.basics.OrganizationalStructureMapper;
import com.yq.cp.mapper.data.CoefficientYearMapper;
import com.yq.cp.mapper.data.NengKongDataDayMapper;
import com.yq.cp.mapper.data.VideoSurveillanceMapper;
import com.yq.cp.mapper.manage.OpsTicketsMessageMapper;
import com.yq.cp.service.data.IndexGfService;
import com.yq.cp.utils.DateTimeUtil;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

@Service
@Transactional
public class IndexGfServiceImpl implements IndexGfService {

    @Resource
    private NengKongDataDayMapper dataDayMapper;
    @Resource
    OrganizationalStructureMapper organizationalStructureMapper;
    @Resource
    private OpsTicketsMessageMapper opsTicketsMessageMapper;
    @Resource
    private EquipmentManagementMapper equipmentManagementMapper;

    @Resource
    VideoSurveillanceMapper videoSurveillanceMapper;
    @Resource
    CoefficientYearMapper coefficientYearMapper;

    @Override
    public Map<String, Object> query1(NengKongDataDay n) {
//        Map<String, Object> map=new HashMap<>();
//        BigDecimal newest=new BigDecimal(0);
//        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//        //发电功率 107
//        n.setType(107);
//        n.setClassifyNumber(2);
//        newest = dataDayMapper.qxdqgl(null);//dataDayMapper.newest(n);
//        map.put("a100",(newest==null?new BigDecimal(0):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"kW");
//
//        //当日发电量 109-发电量（每小时）
//        n.setType(115);
//        n.setClassifyNumber(2);
//        newest = dataDayMapper.newest(n);
//        newest=newest==null?new BigDecimal(0):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
//        BigDecimal qxzxz = dataDayMapper.qxzxz3(null,115, n.getYear());
//        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
//        newest=newest.subtract(qxzxz);
//        BigDecimal dr=newest;
//        map.put("a109",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"kWh");
//        qxzxz = dataDayMapper.qxzxz31(null, 112,n.getYear(),n.getMonth());
//        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
//        BigDecimal qxzdz = dataDayMapper.qxzdz31(null,112,n.getYear(),n.getMonth());
//        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
//        BigDecimal bigDecimal1 = dr.add(qxzdz).subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
//        map.put("a101",bigDecimal1);
//        //总装机
//        n.setType(102);
//        n.setClassifyNumber(1);
//        newest = dataDayMapper.zj(n);
//        map.put("a102",(newest==null?new BigDecimal(0):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)));//+"kW"
//        QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
//        queryWrapper22.eq("year",n.getYear());
//        CoefficientYear coefficientYear = coefficientYearMapper.selectOne(queryWrapper22);
//        if(coefficientYear==null){
//            coefficientYear=new CoefficientYear();
//            coefficientYear.setCoefficient2(new BigDecimal(0));
//            coefficientYear.setCoefficient1(new BigDecimal(0));
//        }
//        map.put("a105",bigDecimal1.multiply(coefficientYear.getCoefficient1()).divide(new BigDecimal(1000*1000)).setScale(3, BigDecimal.ROUND_HALF_UP)+"");//+"t"
//        //碳减排量
//        map.put("a106",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000)).setScale(3, BigDecimal.ROUND_HALF_UP)+"");//+"t"
//        //光伏电站数量 001
//        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
//        queryWrapper.eq("examine",1);
//        queryWrapper.eq("type",6);
//        Long aLong = organizationalStructureMapper.selectCount(queryWrapper);
//        map.put("a001",(aLong==null?0:aLong));
//
//        //运行天数 002
//        n.setType(101);
//        n.setClassifyNumber(1);
//        Long yxts = dataDayMapper.yxts(n);
//        map.put("a002",(yxts==null?0:yxts));

        Map<String, Object> map=new HashMap<>();
        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
        //发电功率 107
        n.setType(107);
        n.setClassifyNumber(2);
        newest = dataDayMapper.qxdqgl(null);//dataDayMapper.newest(n);
        map.put("a100",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"kW");

        //当日发电量 109-发电量（每小时）
        n.setType(115);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal qxzxz = dataDayMapper.qxzxz1(null,DateTimeUtil.getStrDateTime3(new Date()),115);
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        newest=newest.subtract(qxzxz);
        newest=newest.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
        BigDecimal dr=newest;
        map.put("a109",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"kWh");

        //累计发电量  101-发电量（当日）
//        n.setType(101);
//        n.setClassifyNumber(1);
//        BigDecimal A1=newest;
//        newest = dataDayMapper.grandTotal(n);
//        newest= (newest == null) ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest;
//
//        map.put("a101",newest.add(A1).add(dr).divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_HALF_UP));//+"万Kwh"

//
//        qxzxz = dataDayMapper.qxzxz31(null, 112,n.getYear(),n.getMonth());
//        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
//        BigDecimal qxzdz = dataDayMapper.qxzdz31(null,112,n.getYear(),n.getMonth());
//        qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
//        BigDecimal bigDecimal1 = dr.add(qxzdz).subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
//        map.put("a101",bigDecimal1);

        qxzxz = dataDayMapper.qxzxz31(null, 119,n.getYear(),n.getMonth());
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        BigDecimal qxzdz = dataDayMapper.qxzdz31(null,119,n.getYear(),n.getMonth());
        qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
        BigDecimal bigDecimal1 = qxzdz.subtract(qxzxz);
        map.put("a101",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)
        //总装机
        n.setType(102);
        n.setClassifyNumber(1);
        newest = dataDayMapper.zj(n);
        map.put("a102",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"");//+"kW"

        if(n.getYear()==null){

            QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
            queryWrapper22.ge("year",2024);
            List<CoefficientYear> coefficientYears = coefficientYearMapper.selectList(queryWrapper22);
            bigDecimal1=new BigDecimal(0);
            BigDecimal bigDecimal2=new BigDecimal(0);
            for (int i = 0; i < coefficientYears.size(); i++) {
                CoefficientYear coefficientYear1 = coefficientYears.get(i);
                qxzxz = dataDayMapper.qxzxz31(null, 119,coefficientYear1.getYear(),n.getMonth());
                qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                qxzdz = dataDayMapper.qxzdz31(null,119,coefficientYear1.getYear(),n.getMonth());
                qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
                bigDecimal1 = bigDecimal1.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient1()));
                bigDecimal2 = bigDecimal2.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient2()));
            }


            //节煤炭量
            map.put("a105",bigDecimal1.divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //碳减排量
            map.put("a106",bigDecimal2.divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //植树
            map.put("a107",bigDecimal2.divide(new BigDecimal(1000*18.3*40),0, RoundingMode.UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

        }else {
            QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
            queryWrapper22.eq("year",n.getYear());
            CoefficientYear coefficientYear = coefficientYearMapper.selectOne(queryWrapper22);
            //节煤炭量
            map.put("a105",bigDecimal1.multiply(coefficientYear.getCoefficient1()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //碳减排量
            map.put("a106",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //植树
            map.put("a107",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*18.3*40),0, RoundingMode.HALF_UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

        }
        //光伏电站数量 001
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("examine",1);
        queryWrapper.eq("type",6);
        Long aLong = organizationalStructureMapper.selectCount(queryWrapper);
        map.put("a001",(aLong==null?0:aLong));

        //运行天数 002
        n.setType(101);
        n.setClassifyNumber(1);
        Long yxts = dataDayMapper.yxts(n);
        map.put("a002",(yxts==null?"0.00":yxts));

        return map;
    }


    @Override
    public Map<String, Object> query11(NengKongDataDay n) {
        Map<String, Object> map=new HashMap<>();
        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));


        //上网电量
        n.setType(115);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),115);
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        newest=newest.subtract(qxzxz);
        newest=newest.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
        BigDecimal dr=newest;
        BigDecimal c1=newest;
        map.put("c1",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        //总上网电量

        qxzxz = dataDayMapper.qxzxz31(n.getEnergyId(), 115,n.getYear(),n.getMonth());
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        BigDecimal qxzdz = dataDayMapper.qxzdz31(n.getEnergyId(),115,n.getYear(),n.getMonth());
        qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
        BigDecimal bigDecimal1 = qxzdz;
        BigDecimal c2=bigDecimal1.subtract(qxzxz);
        map.put("c2",bigDecimal1.subtract(qxzxz).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)


        //消网电量
        n.setType(116);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
        qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),116);
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        newest=newest.subtract(qxzxz);
        newest=newest.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
        dr=newest;
        BigDecimal a1=newest;
//        map.put("c1",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"kWh");
        //总消网电量

        qxzxz = dataDayMapper.qxzxz31(n.getEnergyId(), 116,n.getYear(),n.getMonth());
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;

        qxzdz = dataDayMapper.qxzdz31(n.getEnergyId(),116,n.getYear(),n.getMonth());
        qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
        bigDecimal1 = qxzdz.subtract(qxzxz);
        BigDecimal a2=bigDecimal1;
//        map.put("c2",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP));//+"kW·h" .divide(new BigDecimal(10000)
        map.put("b1",dr.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("b2",bigDecimal1.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)


        //发电量
        n.setType(119);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
        qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),119);
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        newest=newest.subtract(qxzxz);
        newest=newest.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
        dr=newest;
//        map.put("c1",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"kWh");
        //总发电量

        qxzxz = dataDayMapper.qxzxz31(n.getEnergyId(), 119,n.getYear(),n.getMonth());
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        qxzdz = dataDayMapper.qxzdz31(n.getEnergyId(),119,n.getYear(),n.getMonth());
        qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
        bigDecimal1 = qxzdz.subtract(qxzxz);
//        map.put("c2",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP));//+"kW·h" .divide(new BigDecimal(10000)
        map.put("a1",dr.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("a2",bigDecimal1.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)


        return map;
    }

    @Override
    public Map<String, Object> query2(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            int day = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(109);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
                    list2.add(new BigDecimal(0));
//                    if (nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
//                        list2.add(nengKongDataDay.getValue());
//                    }else {
//                        BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
//                        list2.add(nengKongDataDay.getValue().subtract(qxzxz));
//                    }

                }else {
                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
                    if (value.compareTo(new BigDecimal(0))==0){
                        value=nengKongDataDay.getValue();
                    }
                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
                    if (subtract.compareTo(new BigDecimal(0))<0){
                        subtract=new BigDecimal(0);
                    }
                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(109);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(109);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);

                    BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(109);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }
        return map;
    }

    @Override
    public Map<String, Object> query251(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(indexGfVo.getRq());
            int month = DateTimeUtil.getMonth(indexGfVo.getRq());
            int day = DateTimeUtil.getDay(indexGfVo.getRq());
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(115);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
                    list2.add(new BigDecimal(0));
//                    if (nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
//                        list2.add(nengKongDataDay.getValue());
//                    }else {
//                        BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
//                        list2.add(nengKongDataDay.getValue().subtract(qxzxz));
//                    }

                }else {
                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
                    if (value.compareTo(new BigDecimal(0))==0){
                        value=nengKongDataDay.getValue();
                    }
                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
                    if (subtract.compareTo(new BigDecimal(0))<0){
                        subtract=new BigDecimal(0);
                    }
                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            if (indexGfVo.getYear()==null){
                indexGfVo.setYear(year);
            }
            if (indexGfVo.getMonth()==null){
                indexGfVo.setMonth(month);
            }

            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                if (nengKongDataDay.getMonthNumber()==DateTimeUtil.getMonth() && nengKongDataDay.getV()==DateTimeUtil.getDay()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(115);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();
            if (indexGfVo.getYear()==null){
                indexGfVo.setYear(year);
            }
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getYearNumber()==DateTimeUtil.getYear() && nengKongDataDay.getV()==DateTimeUtil.getMonth()){
                        NengKongDataDay n=new NengKongDataDay();
                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                        BigDecimal newest=new BigDecimal(0);
                        //当日发电量 109-发电量（每小时）
                        n.setType(115);
                        n.setClassifyNumber(2);
                        newest = dataDayMapper.newest(n);

                        BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
                        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                        BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                        nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(115);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==5){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query24(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getV()==DateTimeUtil.getYear()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(115);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);

//                    BigDecimal qxzxz = dataDayMapper.qxzxz3(indexGfVo.getEnergyId(),115, DateTimeUtil.getYear(DateTimeUtil.dqsj()));
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }
    @Override
    public Map<String, Object> query252(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(indexGfVo.getRq());
            int month = DateTimeUtil.getMonth(indexGfVo.getRq());
            int day = DateTimeUtil.getDay(indexGfVo.getRq());
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(117);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
                    list2.add(new BigDecimal(0));
//                    if (nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
//                        list2.add(nengKongDataDay.getValue());
//                    }else {
//                        BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
//                        list2.add(nengKongDataDay.getValue().subtract(qxzxz));
//                    }

                }else {
                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
                    if (value.compareTo(new BigDecimal(0))==0){
                        value=nengKongDataDay.getValue();
                    }
                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
                    if (subtract.compareTo(new BigDecimal(0))<0){
                        subtract=new BigDecimal(0);
                    }
                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();

            if (indexGfVo.getYear()==null){
                indexGfVo.setYear(year);
            }
            if (indexGfVo.getMonth()==null){
                indexGfVo.setMonth(month);
            }
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                if (nengKongDataDay.getMonthNumber()==DateTimeUtil.getMonth() && nengKongDataDay.getV()==DateTimeUtil.getDay()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(117);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),117);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();

            if (indexGfVo.getYear()==null){
                indexGfVo.setYear(year);
            }

            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getYearNumber()==DateTimeUtil.getYear() && nengKongDataDay.getV()==DateTimeUtil.getMonth()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(117);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);

                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),117);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    n.setType(117);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),117);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==5){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query24(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getV()==DateTimeUtil.getYear()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(117);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);

                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),117);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }
    @Override
    public Map<String, Object> query253(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(indexGfVo.getRq());
            int month = DateTimeUtil.getMonth(indexGfVo.getRq());
            int day = DateTimeUtil.getDay(indexGfVo.getRq());
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(116);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
                    list2.add(new BigDecimal(0));
//                    if (nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
//                        list2.add(nengKongDataDay.getValue());
//                    }else {
//                        BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
//                        list2.add(nengKongDataDay.getValue().subtract(qxzxz));
//                    }

                }else {
                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
                    if (value.compareTo(new BigDecimal(0))==0){
                        value=nengKongDataDay.getValue();
                    }
                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
                    if (subtract.compareTo(new BigDecimal(0))<0){
                        subtract=new BigDecimal(0);
                    }
                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();

            if (indexGfVo.getYear()==null){
                indexGfVo.setYear(year);
            }
            if (indexGfVo.getMonth()==null){
                indexGfVo.setMonth(month);
            }
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                if (nengKongDataDay.getMonthNumber()==DateTimeUtil.getMonth() && nengKongDataDay.getV()==DateTimeUtil.getDay()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(116);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),116);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();

            if (indexGfVo.getYear()==null){
                indexGfVo.setYear(year);
            }
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getYearNumber()==DateTimeUtil.getYear() &&nengKongDataDay.getV()==DateTimeUtil.getMonth()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(116);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);

                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),116);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    n.setType(116);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),116);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==5){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query24(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getV()==DateTimeUtil.getYear()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    //当日发电量 109-发电量（每小时）
                    n.setType(116);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);

                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),116);
                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }
    @Override
    public Map<String, Object> query256(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        if (indexGfVo.getTypeNumber()==2){
            List<BigDecimal> cxdxxss = dataDayMapper.cxdxxss(indexGfVo.getId(), DateTimeUtil.getYear(), DateTimeUtil.getMonth());
            map.put("list2",cxdxxss);
        }else if (indexGfVo.getTypeNumber()==3){

            List<BigDecimal> cxdxxss = dataDayMapper.cxdxxss1(indexGfVo.getId(), DateTimeUtil.getYear());
            map.put("list2",cxdxxss);
        }else if (indexGfVo.getTypeNumber()==5){

            List<BigDecimal> cxdxxss = dataDayMapper.cxdxxss2(indexGfVo.getId());
            map.put("list2",cxdxxss);
        }
        return map;
    }
    @Override
    public Map<String, Object> query255(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            int day = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
                    list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//                    if (nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                        list2.add(nengKongDataDay.getValue());
//                    }else {
//                        BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
//                        list2.add(nengKongDataDay.getValue().subtract(qxzxz));
//                    }

                }else {
                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
                    if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                        value=nengKongDataDay.getValue();
                        value=dataDayMapper.qxzxz19(indexGfVo.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),119,nengKongDataDay.getV());
                    }
                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
                    if (subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<0){
                        subtract=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    }
                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    //当日发电量 109-发电量（每小时）
                    n.setType(119);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    //当日发电量 109-发电量（每小时）
                    n.setType(119);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);

                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    n.setType(119);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }

//
//    @Override
//    public Map<String, Object> query254(IndexGfVo indexGfVo) {
//        Map<String, Object> map=new HashMap<>();
//        List<Object> list1=new ArrayList<>();
//        List<Object> list2=new ArrayList<>();
//
//        int year1 = DateTimeUtil.getYear(indexGfVo.getRq());
//        int month1 = DateTimeUtil.getMonth(indexGfVo.getRq());
//        int day1 = DateTimeUtil.getDay(indexGfVo.getRq());
//        if (indexGfVo.getTypeNumber()==1){
//            int year = DateTimeUtil.getYear();
//            int month = DateTimeUtil.getMonth();
//            int day = DateTimeUtil.getDay();
//            indexGfVo.setYear(year);
//            indexGfVo.setMonth(month);
//            indexGfVo.setDay(day);
//            indexGfVo.setType(119);
//
//
//            if (indexGfVo.getMacId()==null){
//                indexGfVo.setMacId(-999l);
//            }
//
//            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
//            for (int i = 0; i < nengKongDataDays.size(); i++) {
//                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
//                list1.add(nengKongDataDay.getV());
//                list2.add(nengKongDataDay.getValue1());
//
////                if (year1==year && month1==month && day1==day ){
////                    String cx=year1+"-"+month1+"-"+day1 +" "+list1.get(i)+":00:00";
////                    Date simpleDateTime = DateTimeUtil.toSimpleDateTime(cx);
////                    if(simpleDateTime.after(DateTimeUtil.dqsj())){
////                        list2.add("");
////                        continue;
////                    }
////                }
////
////                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0))==0){
////                    list2.add(new BigDecimal(0));
////                }else {
////                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
////                    if (value.compareTo(new BigDecimal(0))==0){
////                        value=nengKongDataDay.getValue();
////                    }
////                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
////                    if (subtract.compareTo(new BigDecimal(0))<0){
////                        subtract=new BigDecimal(0);
////                    }
////                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
////                }
//            }
//            map.put("list1",list1);
//            map.put("list2",list2);
//        }else if (indexGfVo.getTypeNumber()==2){
//            int year = DateTimeUtil.getYear();
//            int month = DateTimeUtil.getMonth();
//            int day = DateTimeUtil.getDay();
//            indexGfVo.setYear(year);
//            indexGfVo.setMonth(month);
//            indexGfVo.setType(indexGfVo.getType());
//            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
//            for (int i = 0; i < nengKongDataDays.size(); i++) {
//                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
//                list1.add(nengKongDataDay.getV());
//
//
//
//                if (year1==year && month1==month && nengKongDataDay.getV()>day){
//                    list2.add("");
//                    continue;
//                }
//
//                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
//                    NengKongDataDay n=new NengKongDataDay();
//                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                    BigDecimal newest=new BigDecimal(0);
//                    //当日发电量 109-发电量（每小时）
//                    n.setType(119);
//                    n.setClassifyNumber(2);
//                    n.setMacId(indexGfVo.getMacId());
//                    newest = dataDayMapper.newest(n);
//                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
//                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);
//
//                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
//
//                }
//                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
//            }
//            map.put("list1",list1);
//            map.put("list2",list2);
//        }else if (indexGfVo.getTypeNumber()==3){
//            int year = DateTimeUtil.getYear();
//            int month = DateTimeUtil.getMonth();
//            indexGfVo.setYear(year);
//            indexGfVo.setType(indexGfVo.getType());
//            indexGfVo.setType(119);
//            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
//            for (int i = 0; i < nengKongDataDays.size(); i++) {
//                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
//                list1.add(nengKongDataDay.getV());
//
//
//                if (year1==year && nengKongDataDay.getV()>month){
//                    list2.add("");
//                    continue;
//                }
//
////                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
////                    NengKongDataDay n=new NengKongDataDay();
////                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
////                    BigDecimal newest=new BigDecimal(0);
////                    //当日发电量 109-发电量（每小时）
////                    n.setType(119);
////                    n.setClassifyNumber(2);
////                    n.setMacId(indexGfVo.getMacId());
////                    newest = dataDayMapper.newest(n);
////
////                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
////                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
////                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);
////
////                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
////                }
//                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
//            }
//            map.put("list1",list1);
//            map.put("list2",list2);
//        }else if(indexGfVo.getTypeNumber()==4){
//            int year = DateTimeUtil.getYear();
//            int month = DateTimeUtil.getMonth();
//            indexGfVo.setYear(year);
//            indexGfVo.setMonth(month);
//            indexGfVo.setType(indexGfVo.getType());
//            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
//            for (int i = 0; i < nengKongDataDays.size(); i++) {
//                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
//                list1.add(nengKongDataDay.getD());
//                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
//                    NengKongDataDay n=new NengKongDataDay();
//                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                    BigDecimal newest=new BigDecimal(0);
//                    n.setType(119);
//                    n.setClassifyNumber(2);
//                    n.setMacId(indexGfVo.getMacId());
//                    newest = dataDayMapper.newest(n);
//                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
//                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);
//
//                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
//
//                }
//                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
//            }
//            map.put("list1",list1);
//            map.put("list2",list2);
//        }else if (indexGfVo.getTypeNumber()==5){
//            int year = DateTimeUtil.getYear();
//            indexGfVo.setYear(year);
//            indexGfVo.setType(indexGfVo.getType());
//            indexGfVo.setType(119);
//            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query24(indexGfVo);
//            for (int i = 0; i < nengKongDataDays.size(); i++) {
//                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
//                list1.add(nengKongDataDay.getV());
//
////                if (nengKongDataDay.getV()==DateTimeUtil.getYear()){
////                    NengKongDataDay n=new NengKongDataDay();
////                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
////                    BigDecimal newest=new BigDecimal(0);
////                    //当日发电量 109-发电量（每小时）
////                    n.setType(119);
////                    n.setClassifyNumber(2);
////                    n.setMacId(indexGfVo.getMacId());
////                    newest = dataDayMapper.newest(n);
////
////                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
////                    qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
////                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0) : newest).subtract(qxzxz);
////
////                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract);
////                }
//                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
//            }
//            map.put("list1",list1);
//            map.put("list2",list2);
//        }
//        return map;
//    }


    @Override
    public Map<String, Object> query254(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();


        int year1 = DateTimeUtil.getYear(indexGfVo.getRq());
        int month1 = DateTimeUtil.getMonth(indexGfVo.getRq());
        int day1 = DateTimeUtil.getDay(indexGfVo.getRq());

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int month = DateTimeUtil.getMonth(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int day = DateTimeUtil.getDay(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));


            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(119);
            if (indexGfVo.getMacId()==null){
                indexGfVo.setMacId(-999l);
            }
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());


                if (year1==year && month1==month && day1==day ){
                    String cx=year1+"-"+month1+"-"+day1 +" "+list1.get(i)+":00:00";
                    Date simpleDateTime = DateTimeUtil.toSimpleDateTime(cx);
                    if(simpleDateTime.after(DateTimeUtil.dqsj())){
                        list2.add("");
                        continue;
                    }
                }
                list2.add(nengKongDataDay.getValue1());
//                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//                }else {
//                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
//                    if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//
//                        value=dataDayMapper.qxzxz19(indexGfVo.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),119,nengKongDataDay.getV());
//                    }
//                    value=value==null?new BigDecimal(0):value;
//                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
//                    if (subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<0){
//                        subtract=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    }
//                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
//                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = indexGfVo.getYear();//DateTimeUtil.getYear();
            int month = indexGfVo.getMonth();//DateTimeUtil.getMonth();
            int day = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());


                if (year1==year && month1==month && nengKongDataDay.getV()>day){
                    list2.add("");
                    continue;
                }

//                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
//                    NengKongDataDay n=new NengKongDataDay();
//                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    //当日发电量 109-发电量（每小时）
//                    n.setType(119);
//                    n.setClassifyNumber(2);
//                    n.setMacId(indexGfVo.getMacId());
//                    newest = dataDayMapper.newest(n);
//                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
//                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);
//
//                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);
//
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = indexGfVo.getYear();//DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (year1==year && nengKongDataDay.getV()>month){
                    list2.add("");
                    continue;
                }

//                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
//                    NengKongDataDay n=new NengKongDataDay();
//                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    //当日发电量 109-发电量（每小时）
//                    n.setType(119);
//                    n.setClassifyNumber(2);
//                    n.setMacId(indexGfVo.getMacId());
//                    newest = dataDayMapper.newest(n);
//
//                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
//                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);
//
//                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    n.setType(119);
                    n.setClassifyNumber(2);
                    n.setMacId(indexGfVo.getMacId());
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==5) {
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query26(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }

    public Map<String, Object> query30(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<String> list1=new ArrayList<>();
        List<BigDecimal> list2=new ArrayList<>();

            int year = DateTimeUtil.getYear(indexGfVo.getTime());
            int month = DateTimeUtil.getMonth(indexGfVo.getTime());
            int day = DateTimeUtil.getDay(indexGfVo.getTime());
        int year1 = DateTimeUtil.getYear();
        int month1 = DateTimeUtil.getMonth();
        int day1 = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(indexGfVo.getType());
            if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
            }

            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20111(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
//                if (i%5!=0){
//                    continue;
//                }
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                Integer v1 = nengKongDataDay.getV();
                Integer m1 = nengKongDataDay.getMinuteNumber();
                if (i<nengKongDataDays.size()-1){
                    NengKongDataDay n2 = nengKongDataDays.get(i+1);
                    Integer v2 = n2.getV();
                    Integer m2 = n2.getMinuteNumber();
                    Integer a=0;
                    while (v1!=v2 || m1!=m2 ){//|| (v1<v2 && m1!=60)

                        if (m1<10){
                            list1.add(v1+":0"+m1);
                        }else {
                            list1.add(v1+":"+m1);
                        }
                        m1=m1+1;
//                        list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));//
                        if (i!=0){
                            NengKongDataDay na = nengKongDataDays.get(i-1);
                            BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                            list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                        }
                        a++;
                        if (m1==60){
                            m1=0;
                            v1++;
                        }
                    }
                    if (a==0){
                        if (m1<10){
                            if (m1>0 && m1<5){
                                list1.add(v1+":00");
                            }else {
                                list1.add(v1+":0"+m1);
                            }
                        }else {
                            list1.add(v1+":"+m1);
                        }
                        if (i!=0){
                            NengKongDataDay na = nengKongDataDays.get(i-1);
                            BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                            list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                        }

                    }

                }else {
                    if (m1<10){
                        if (m1>0 && m1<5){
                            list1.add(v1+":00");
                        }else {
                            list1.add(v1+":0"+m1);
                        }
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                        BigDecimal value1 = na.getValue();
//                        value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                    }

                }

//                if (nengKongDataDay.getMinuteNumber()==null){
//                    list1.add(nengKongDataDay.getV()+":00");//
//                }else {
//                    if (nengKongDataDay.getMinuteNumber()<10){
//                        if (nengKongDataDay.getMinuteNumber()>0 && nengKongDataDay.getMinuteNumber()<5){
//                            list1.add(nengKongDataDay.getV()+":00");
//                        }else {
//                            list1.add(nengKongDataDay.getV()+":0"+nengKongDataDay.getMinuteNumber());
//                        }
//                    }else {
//                        list1.add(nengKongDataDay.getV()+":"+nengKongDataDay.getMinuteNumber());
//                    }
//
//                }
//
//                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }

        List<Object> list11=new ArrayList<>();
        List<BigDecimal> list22=new ArrayList<>();
        int A=0;
        for (int i = 0; i < list2.size(); i++) {
            if (i%5!=0){
                continue;
            }
            if (list1.get(i).equals("11:55")){
                System.out.println(123);
            }
            BigDecimal value = list2.get(i);
            if (i==0){
                value=new BigDecimal(0);//value.divide(new BigDecimal(5*60),2);
            }else {
                BigDecimal value1 = list2.get(i-5);
                BigDecimal subtract = value.subtract(value1);
                subtract=subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract;
                subtract=subtract.multiply(new BigDecimal(1000));
                value=subtract.divide(new BigDecimal(5*60),2);
            }

            if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
//                String s = list1.get(i);
//                String[] split = s.split(":");
//                int i1 = Integer.parseInt(split[0]);
//                int i2 = Integer.parseInt(split[1]);
//                Integer hour = DateTimeUtil.getHour();
//                Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());
//                if (((i1==hour && i2>minute) || (i1<hour )) && i1>8 && value.compareTo(new BigDecimal(0))==0){
//                    value=null;
//                }
                if (value.compareTo(new BigDecimal(0))==0){
                    value=null;
                }
            }


            list11.add(list1.get(i));
            list22.add(value);
            A++;
        }
            map.put("list1",list11);
            map.put("list2",list22);

        return map;
    }

    @Override
    public Map<String, Object> query3(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<String> list1=new ArrayList<>();
        List<BigDecimal> list2=new ArrayList<>();
        Integer hour = DateTimeUtil.getHour();
        Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());

        int year = DateTimeUtil.getYear(indexGfVo.getTime());
        int month = DateTimeUtil.getMonth(indexGfVo.getTime());
        int day = DateTimeUtil.getDay(indexGfVo.getTime());
        int year1 = DateTimeUtil.getYear();
        int month1 = DateTimeUtil.getMonth();
        int day1 = DateTimeUtil.getDay();
        indexGfVo.setYear(year);
        indexGfVo.setMonth(month);
        indexGfVo.setDay(day);
        indexGfVo.setType(indexGfVo.getType());
        indexGfVo.setEnergyId(indexGfVo.getId());
        Integer cxjr=0;
        if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
            cxjr=1;
        }

        List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20111(indexGfVo);
        for (int i = 0; i < nengKongDataDays.size(); i++) {
//                if (i%5!=0){
//                    continue;
//                }
            NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
            Integer v1 = nengKongDataDay.getV();
            Integer m1 = nengKongDataDay.getMinuteNumber();
            if (i<nengKongDataDays.size()-1){
                NengKongDataDay n2 = nengKongDataDays.get(i+1);
                Integer v2 = n2.getV();
                Integer m2 = n2.getMinuteNumber();
                Integer a=0;
                while (v1!=v2 || m1!=m2 ){//|| (v1<v2 && m1!=60)

                    if (m1<10){
                        list1.add(v1+":0"+m1);
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (cxjr==1 && (v1>hour || (v1==hour && m1>minute))){
                        list2.add(new BigDecimal(0));
                    }else {
                        list2.add(nengKongDataDay.getValue().setScale(3, BigDecimal.ROUND_HALF_UP));//

                    }
                    m1=m1+1;
                    a++;
                    if (m1==60){
                        m1=0;
                        v1++;
                    }
                }
                if (a==0){
                    if (m1<10){
                        if (m1>0 && m1<5){
                            list1.add(v1+":00");
                        }else {
                            list1.add(v1+":0"+m1);
                        }
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(3, BigDecimal.ROUND_HALF_UP));
                    }else {

                        list2.add(nengKongDataDay.getValue().setScale(3, BigDecimal.ROUND_HALF_UP));
                    }

                }

            }else {
                if (m1<10){
                    if (m1>0 && m1<5){
                        list1.add(v1+":00");
                    }else {
                        list1.add(v1+":0"+m1);
                    }
                }else {
                    list1.add(v1+":"+m1);
                }
                if (i!=0){
                    NengKongDataDay na = nengKongDataDays.get(i-1);
                    BigDecimal value = nengKongDataDay.getValue();
//                        BigDecimal value1 = na.getValue();
//                        value=value.subtract(value1).multiply(new BigDecimal(1000));
                    list2.add(value.setScale(3, BigDecimal.ROUND_HALF_UP));
                }else {

                    list2.add(nengKongDataDay.getValue().setScale(3, BigDecimal.ROUND_HALF_UP));
                }

            }

//                if (nengKongDataDay.getMinuteNumber()==null){
//                    list1.add(nengKongDataDay.getV()+":00");//
//                }else {
//                    if (nengKongDataDay.getMinuteNumber()<10){
//                        if (nengKongDataDay.getMinuteNumber()>0 && nengKongDataDay.getMinuteNumber()<5){
//                            list1.add(nengKongDataDay.getV()+":00");
//                        }else {
//                            list1.add(nengKongDataDay.getV()+":0"+nengKongDataDay.getMinuteNumber());
//                        }
//                    }else {
//                        list1.add(nengKongDataDay.getV()+":"+nengKongDataDay.getMinuteNumber());
//                    }
//
//                }
//
        }

        List<Object> list11=new ArrayList<>();
        List<BigDecimal> list22=new ArrayList<>();
        int A=0;
        for (int i = 0; i < list2.size(); i++) {

//            System.out.println(list1.get(i)+"--"+list2.get(i));
            if (i%5!=0){
                continue;
            }
            BigDecimal value = list2.get(i);
            if (i==0){
                value=new BigDecimal(0);//value.divide(new BigDecimal(5*60),2);
            }else {
                BigDecimal value1 = list2.get(i-5);
                BigDecimal subtract =value;// value.subtract(value1);
                subtract=subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract;
//                subtract=subtract.divide(new BigDecimal(1000),2);
                value=subtract;
//                value=subtract.divide(new BigDecimal(5*60),2);
            }

            if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
//                String s = list1.get(i);
//                String[] split = s.split(":");
//                int i1 = Integer.parseInt(split[0]);
//                int i2 = Integer.parseInt(split[1]);
//                Integer hour = DateTimeUtil.getHour();
//                Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());
//                if (((i1==hour && i2>minute) || (i1<hour )) && i1>8 && value.compareTo(new BigDecimal(0))==0){
//                    value=null;
//                }
                if (value.compareTo(new BigDecimal(0))==0){
                    value=null;
                }
            }else {

            }

            if (year1==year && month1==month && day1==day ){
                String cx=year1+"-"+month1+"-"+day1 +" "+list1.get(i)+":00";
                Date simpleDateTime = DateTimeUtil.toSimpleDateTime(cx);
                if(simpleDateTime.after(DateTimeUtil.dqsj())){
                    list22.add(null);
                }else {
                    list22.add(value);
                }
            }else {
                list22.add(value);
            }
            list11.add(list1.get(i));

            A++;
        }
        map.put("list1",list11);
        map.put("list2",list22);

        return map;
    }
    @Override
    public Map<String, Object> query31(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<BigDecimal> list2=new ArrayList<>();

        int year = DateTimeUtil.getYear(indexGfVo.getTime());
        int month = DateTimeUtil.getMonth(indexGfVo.getTime());
        int day = DateTimeUtil.getDay(indexGfVo.getTime());
        int year1 = DateTimeUtil.getYear();
        int month1 = DateTimeUtil.getMonth();
        int day1 = DateTimeUtil.getDay();
        indexGfVo.setYear(year);
        indexGfVo.setMonth(month);
        indexGfVo.setDay(day);
        indexGfVo.setType(indexGfVo.getType());
        if (year1==year && month1==month && day1==day ){
            indexGfVo.setCxjr(1);
        }

        List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20111(indexGfVo);
        for (int i = 0; i < nengKongDataDays.size(); i++) {
//                if (i%5!=0){
//                    continue;
//                }
            NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
            Integer v1 = nengKongDataDay.getV();
            Integer m1 = nengKongDataDay.getMinuteNumber();
            if (i<nengKongDataDays.size()-1){
                NengKongDataDay n2 = nengKongDataDays.get(i+1);
                Integer v2 = n2.getV();
                Integer m2 = n2.getMinuteNumber();
                Integer a=0;
                while (v1!=v2 || m1!=m2 ){//|| (v1<v2 && m1!=60)

                    if (m1<10){
                        list1.add(v1+":0"+m1);
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    m1=m1+1;
//                        list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));//
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                    }
                    a++;
                    if (m1==60){
                        m1=0;
                        v1++;
                    }
                }
                if (a==0){
                    if (m1<10){
                        if (m1>0 && m1<5){
                            list1.add(v1+":00");
                        }else {
                            list1.add(v1+":0"+m1);
                        }
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                    }

                }

            }else {
                if (m1<10){
                    if (m1>0 && m1<5){
                        list1.add(v1+":00");
                    }else {
                        list1.add(v1+":0"+m1);
                    }
                }else {
                    list1.add(v1+":"+m1);
                }
                if (i!=0){
                    NengKongDataDay na = nengKongDataDays.get(i-1);
                    BigDecimal value = nengKongDataDay.getValue();
//                        BigDecimal value1 = na.getValue();
//                        value=value.subtract(value1).multiply(new BigDecimal(1000));
                    list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                }

            }

//                if (nengKongDataDay.getMinuteNumber()==null){
//                    list1.add(nengKongDataDay.getV()+":00");//
//                }else {
//                    if (nengKongDataDay.getMinuteNumber()<10){
//                        if (nengKongDataDay.getMinuteNumber()>0 && nengKongDataDay.getMinuteNumber()<5){
//                            list1.add(nengKongDataDay.getV()+":00");
//                        }else {
//                            list1.add(nengKongDataDay.getV()+":0"+nengKongDataDay.getMinuteNumber());
//                        }
//                    }else {
//                        list1.add(nengKongDataDay.getV()+":"+nengKongDataDay.getMinuteNumber());
//                    }
//
//                }
//
//                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
        }

        List<Object> list11=new ArrayList<>();
        List<BigDecimal> list22=new ArrayList<>();
        int A=0;
        for (int i = 0; i < list2.size(); i++) {
            if (i%5!=0){
                continue;
            }
            BigDecimal value = list2.get(i);
//            if (i==0){
//                value=value.divide(new BigDecimal(5*60),2);
//            }else {
//                BigDecimal value1 = list22.get(list22.size()-1);
//                value=value.subtract(value1).divide(new BigDecimal(5*60),2);
//            }

            list11.add(list1.get(i));
            list22.add(value);
            A++;
        }
        map.put("list1",list11);
        map.put("list2",list22);

        return map;
    }
    @Override
    public Map<String, Object> query32(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<String> list1=new ArrayList<>();
        List<BigDecimal> list2=new ArrayList<>();
        Integer hour = DateTimeUtil.getHour();
        Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());

        int year = DateTimeUtil.getYear(indexGfVo.getRq());
        int month = DateTimeUtil.getMonth(indexGfVo.getRq());
        int day = DateTimeUtil.getDay(indexGfVo.getRq());
        int year1 = DateTimeUtil.getYear();
        int month1 = DateTimeUtil.getMonth();
        int day1 = DateTimeUtil.getDay();
        indexGfVo.setYear(year);
        indexGfVo.setMonth(month);
        indexGfVo.setDay(day);
        indexGfVo.setType(indexGfVo.getType());
        indexGfVo.setEnergyId(indexGfVo.getId());
        Integer cxjr=0;
        if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
            cxjr=1;
        }

        List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20114(indexGfVo);
        for (int i = 0; i < nengKongDataDays.size(); i++) {
//                if (i%5!=0){
//                    continue;
//                }
            NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
            Integer v1 = nengKongDataDay.getV();
            Integer m1 = nengKongDataDay.getMinuteNumber();
            if (i<nengKongDataDays.size()-1){
                NengKongDataDay n2 = nengKongDataDays.get(i+1);
                Integer v2 = n2.getV();
                Integer m2 = n2.getMinuteNumber();
                Integer a=0;
                while (v1!=v2 || m1!=m2 ){//|| (v1<v2 && m1!=60)

                    if (m1<10){
                        list1.add(v1+":0"+m1);
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (cxjr==1 && (v1>hour || (v1==hour && m1>minute))){
                        list2.add(new BigDecimal(0));
                    }else {
                        list2.add(nengKongDataDay.getValue().setScale(3, BigDecimal.ROUND_HALF_UP));//

                    }
                    m1=m1+1;
                    a++;
                    if (m1==60){
                        m1=0;
                        v1++;
                    }
                }
                if (a==0){
                    if (m1<10){
                        if (m1>0 && m1<5){
                            list1.add(v1+":00");
                        }else {
                            list1.add(v1+":0"+m1);
                        }
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(3, BigDecimal.ROUND_HALF_UP));
                    }else {

                        list2.add(nengKongDataDay.getValue().setScale(3, BigDecimal.ROUND_HALF_UP));
                    }

                }

            }else {
                if (m1<10){
                    if (m1>0 && m1<5){
                        list1.add(v1+":00");
                    }else {
                        list1.add(v1+":0"+m1);
                    }
                }else {
                    list1.add(v1+":"+m1);
                }
                if (i!=0){
                    NengKongDataDay na = nengKongDataDays.get(i-1);
                    BigDecimal value = nengKongDataDay.getValue();
//                        BigDecimal value1 = na.getValue();
//                        value=value.subtract(value1).multiply(new BigDecimal(1000));
                    list2.add(value.setScale(3, BigDecimal.ROUND_HALF_UP));
                }else {

                    list2.add(nengKongDataDay.getValue().setScale(3, BigDecimal.ROUND_HALF_UP));
                }

            }

//                if (nengKongDataDay.getMinuteNumber()==null){
//                    list1.add(nengKongDataDay.getV()+":00");//
//                }else {
//                    if (nengKongDataDay.getMinuteNumber()<10){
//                        if (nengKongDataDay.getMinuteNumber()>0 && nengKongDataDay.getMinuteNumber()<5){
//                            list1.add(nengKongDataDay.getV()+":00");
//                        }else {
//                            list1.add(nengKongDataDay.getV()+":0"+nengKongDataDay.getMinuteNumber());
//                        }
//                    }else {
//                        list1.add(nengKongDataDay.getV()+":"+nengKongDataDay.getMinuteNumber());
//                    }
//
//                }
//
        }

        List<Object> list11=new ArrayList<>();
        List<BigDecimal> list22=new ArrayList<>();
        int A=0;
        for (int i = 0; i < list2.size(); i++) {

//            System.out.println(list1.get(i)+"--"+list2.get(i));
            if (i%5!=0){
                continue;
            }
            BigDecimal value = list2.get(i);
            if (i==0){
                value=new BigDecimal(0);//value.divide(new BigDecimal(5*60),2);
            }else {
                BigDecimal value1 = list2.get(i-5);
                BigDecimal subtract =value;// value.subtract(value1);
                subtract=subtract.compareTo(new BigDecimal(0))==-1?new BigDecimal(0):subtract;
//                subtract=subtract.divide(new BigDecimal(1000),2);
                value=subtract;
//                value=subtract.divide(new BigDecimal(5*60),2);
            }

            if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
//                String s = list1.get(i);
//                String[] split = s.split(":");
//                int i1 = Integer.parseInt(split[0]);
//                int i2 = Integer.parseInt(split[1]);
//                Integer hour = DateTimeUtil.getHour();
//                Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());
//                if (((i1==hour && i2>minute) || (i1<hour )) && i1>8 && value.compareTo(new BigDecimal(0))==0){
//                    value=null;
//                }
                if (value.compareTo(new BigDecimal(0))==0){
                    value=null;
                }
            }else {

            }

            if (year1==year && month1==month && day1==day ){
                String cx=year1+"-"+month1+"-"+day1 +" "+list1.get(i)+":00";
                Date simpleDateTime = DateTimeUtil.toSimpleDateTime(cx);
                if(simpleDateTime.after(DateTimeUtil.dqsj())){
                    list22.add(null);
                }else {
                    list22.add(value);
                }
            }else {
                list22.add(value);
            }
            list11.add(list1.get(i));

            A++;
        }
        map.put("list1",list11);
        map.put("list2",list22);

        return map;
    }


    @Override
    public List<NyzfdqkDto> query4() {
        List<NyzfdqkDto> list=new ArrayList<>();
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("examine",1);
        queryWrapper.eq("type",6);
        List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(queryWrapper);
        for (int i = 0; i < energyStations.size(); i++) {
            OrganizationalStructure organizationalStructure = energyStations.get(i);
            NyzfdqkDto dto=new NyzfdqkDto();
            dto.setId(organizationalStructure.getId());
            dto.setName(organizationalStructure.getName());
            Integer d=organizationalStructure.getInstalledCapacity()==null?0:organizationalStructure.getInstalledCapacity().intValue();
            dto.setZjrl(d+"kWp");
            BigDecimal newest=new BigDecimal(0);
            NengKongDataDay n=new NengKongDataDay();
            n.setType(113);
            n.setClassifyNumber(2);
            n.setYear(DateTimeUtil.getYear());
            n.setEnergyId(organizationalStructure.getId());
            newest = dataDayMapper.newest(n);
            dto.setFdl((newest==null?new BigDecimal(0):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"kW");

            //辐照强度（每小时）108
            n.setType(108);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            dto.setSsfsqd((newest==null?new BigDecimal(0):newest.setScale(2, BigDecimal.ROUND_HALF_UP))+"W/㎡");

            //有效小时
//            n.setType(104);
//            n.setYear(DateTimeUtil.getYear());
//            n.setClassifyNumber(1);
//            n.setEnergyId(energyStation.getId());
//            BigDecimal bigDecimal = dataDayMapper.grandTotal(n);
//            BigDecimal bigDecimal1 = bigDecimal == null ? new BigDecimal(0) : bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);
//            bigDecimal1=bigDecimal1.add(new BigDecimal(jrxss));

//            Long jrxss = dataDayMapper.ljxss(energyStation.getId());
//            jrxss=jrxss==null?0:jrxss;
//            dto.setYxxss(jrxss+"h");


            //有效小时
            BigDecimal qxzxz = dataDayMapper.qxzxz(organizationalStructure.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
            qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

            BigDecimal qxzdz = dataDayMapper.qxzdz(organizationalStructure.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
            qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
            BigDecimal subtract = qxzdz.subtract(qxzxz);
            if (organizationalStructure==null){
                dto.setYxxss(0+"h");
            }else {
                BigDecimal installedCapacity = organizationalStructure.getInstalledCapacity();
                if (installedCapacity==null || installedCapacity.compareTo(new BigDecimal(0))==0){
                    dto.setYxxss(0+"h");
                }else {
                    dto.setYxxss(subtract.divide(installedCapacity,2).setScale(2, BigDecimal.ROUND_HALF_UP)+"h");
                }

            }
            dto.setDataPhoto(organizationalStructure.getDataPhoto());
            list.add(dto);
        }
        return list;
    }

    @Override
    public List<NyzfdqkDto> query5() {
        List<NyzfdqkDto> list=new ArrayList<>();
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("examine",1);
        queryWrapper.eq("type",6);
        List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(queryWrapper);
        for (int i = 0; i < energyStations.size(); i++) {
            OrganizationalStructure organizationalStructure = energyStations.get(i);
            NyzfdqkDto dto=new NyzfdqkDto();
            dto.setId(organizationalStructure.getId());
            dto.setName(organizationalStructure.getName());
            dto.setCode(organizationalStructure.getCode());




            BigDecimal newest=new BigDecimal(0);
            NengKongDataDay n=new NengKongDataDay();

            //当日发电量 109-发电量（每小时）
            n.setYear(DateTimeUtil.getYear());
            n.setEnergyId(organizationalStructure.getId());
            n.setType(115);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            newest=newest==null?new BigDecimal(0):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
            BigDecimal qxzxz = dataDayMapper.qxzxz3(organizationalStructure.getId(),115, null);
            qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
            newest=newest.subtract(qxzxz);
            BigDecimal dr=newest;
            if (dr.compareTo(new BigDecimal(0))==-1){
                dr=new BigDecimal(0);
            }


            n.setType(101);
            n.setClassifyNumber(1);
//            newest = dataDayMapper.grandTotal(n);
//            newest=newest==null?new BigDecimal(0):newest.setScale(2, BigDecimal.ROUND_HALF_UP);



            //今日
//            n.setType(109);
//            n.setClassifyNumber(2);
//            BigDecimal n2 = dataDayMapper.newest(n);
//            n2=n2==null?new BigDecimal(0):n2.setScale(2, BigDecimal.ROUND_HALF_UP);
            qxzxz = dataDayMapper.qxzxz1(organizationalStructure.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),112);
            qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;
            BigDecimal qxzdz = dataDayMapper.qxzdz1(organizationalStructure.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),112);
            qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
            //今日
            dto.setFdl(dr.add(qxzdz).subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP)+"kW·h");

            n.setType(101);
            n.setClassifyNumber(1);
            Long yxts = dataDayMapper.yxts(n);
            dto.setYxsj((yxts==null?0:yxts)+"天");
            dto.setScwb(DateTimeUtil.getStrDateTime3(organizationalStructure.getScwb()));

            BigDecimal fdl = dataDayMapper.cxcz(organizationalStructure.getCode(),"production", "发电量总");
            BigDecimal swdl = dataDayMapper.cxcz(organizationalStructure.getCode(),"up", "发电量总");

            String dbyxzt="";
            if (swdl.compareTo(new BigDecimal(0))==0 && fdl.compareTo(new BigDecimal(0))!=0){
                dbyxzt="全额消纳";
            }else if (swdl.compareTo(new BigDecimal(0))==0 && fdl.compareTo(new BigDecimal(0))==0){
                dbyxzt="暂停运行";
            }else if (swdl.compareTo(new BigDecimal(0))!=0 && fdl.compareTo(swdl)==0){
                dbyxzt="全额上网";
            }else if (swdl.compareTo(fdl)==-1){
                dbyxzt="部分消纳";
            }

            dto.setDbyxzt(dbyxzt);
            list.add(dto);



        }
        return list;
    }
    @Override
    public Map<String, Object> query6(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();
        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            int day = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(indexGfVo.getType()+3);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                if (nengKongDataDay.getV().equals(String.valueOf(DateTimeUtil.getDay()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    n.setType(indexGfVo.getType()+3);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(newest==null?new BigDecimal(0):newest));
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else {
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getV().equals(String.valueOf(DateTimeUtil.getMonth()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0);
                    n.setType(indexGfVo.getType()+3);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(newest==null?new BigDecimal(0):newest));
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }
        return map;
    }
    @Override
    public Map<String, Object> nyzQuery1(NengKongDataDay n) {
        n.setEnergyId(n.getId());
        Map<String, Object> map=new HashMap<>();
        BigDecimal newest=new BigDecimal(0);
        n.setTime(DateTimeUtil.toSimpleDate(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj())));
        //发电功率 107
        n.setType(107);
        n.setClassifyNumber(2);
        newest = dataDayMapper.qxdqgl(null);//dataDayMapper.newest(n);
        map.put("a1",(newest==null?new BigDecimal(0):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)));//发电功率+"kw·h"

        //108-辐照强度（每小时）
        n.setType(108);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        map.put("a2",(newest==null?new BigDecimal(0):newest.setScale(2, BigDecimal.ROUND_HALF_UP)));//辐照强度+"kwh/m²"

        //110-温度
        n.setType(110);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        map.put("a3",(newest==null?new BigDecimal(0):newest.doubleValue()));//温度+"℃"

        //111-湿度
        n.setType(111);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        map.put("a4",(newest==null?new BigDecimal(0):newest.doubleValue()));//湿度+"%"

        //有效小时
        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

        BigDecimal qxzdz = dataDayMapper.qxzdz1(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
        BigDecimal subtract = qxzdz.subtract(qxzxz);
        OrganizationalStructure organizationalStructure = organizationalStructureMapper.selectById(n.getId());
        if (organizationalStructure==null){
            map.put("a5",0);
        }else {
            BigDecimal installedCapacity = organizationalStructure.getInstalledCapacity();
            if (installedCapacity==null){
                map.put("a5",0);
            }else {
                map.put("a5",subtract.divide(installedCapacity,2).setScale(2, BigDecimal.ROUND_HALF_UP));
            }

        }

//        n.setType(104);
//        n.setYear(DateTimeUtil.getYear());
//        n.setClassifyNumber(1);
//        n.setEnergyId(n.getId());
//        Long yxts = dataDayMapper.yxts(n);
//        Long A1=yxts==null?0l:yxts;
//        Long jrxss = dataDayMapper.jrxss(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//        jrxss=jrxss==null?0:jrxss;
//        map.put("a5",A1+jrxss);//有效小时+"h"
        return map;
    }

    @Override
    public Map<String, Object> nyzQuery4(NengKongDataDay n) {
        n.setEnergyId(n.getId());
        Map<String, Object> map=new HashMap<>();
        BigDecimal newest=new BigDecimal(0);

        //有效小时
        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),115);
        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

        BigDecimal qxzdz = dataDayMapper.qxzdz1(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),115);
        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
        BigDecimal subtract = qxzdz.subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
        map.put("dr",subtract);

//        n.setType(104);
//        n.setYear(DateTimeUtil.getYear());
//        n.setClassifyNumber(1);
//        n.setEnergyId(n.getId());
//        Long yxts = dataDayMapper.yxts(n);
//        Long A1=yxts==null?0l:yxts;
//        Long jrxss = dataDayMapper.jrxss(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//        jrxss=jrxss==null?0:jrxss;
//        map.put("a5",A1+jrxss);//有效小时+"h"
        return map;
    }

    @Override
    public Map<String, Object> nyzQuery2(NengKongDataDay n) {
        n.setEnergyId(n.getId());
        Map<String, Object> map=new HashMap<>();
        map.put("a1","0.00");//发电量+"万Kwh"
        map.put("a2","0.00");//系统效率+"%"
        map.put("a3","0.00");//总装机+"kWp"
        map.put("a4","0.00");//节煤量+"t"
        map.put("a5","0.00");//碳减排量+"t"
        map.put("a6","0");//运行天数+"t"

        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);

        //当日发电量 109-发电量（每小时）
        n.setType(115);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal qxzxz = dataDayMapper.qxzxz(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        newest=newest.subtract(qxzxz);
        BigDecimal dr=newest;
        map.put("a109",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//kWh

        qxzxz = dataDayMapper.qxzxz31(n.getId(), 119,n.getYear(),n.getMonth());
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        BigDecimal qxzdz = dataDayMapper.qxzdz31(n.getId(),119,n.getYear(),n.getMonth());
        qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
        BigDecimal bigDecimal1 = qxzdz.subtract(qxzxz);
        map.put("a1",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)

        //总装机
        n.setType(102);
        n.setClassifyNumber(1);
        newest = dataDayMapper.zj(n);
        map.put("a3",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"");

//        QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
//        queryWrapper22.eq("year",n.getYear());
//        CoefficientYear coefficientYear = coefficientYearMapper.selectOne(queryWrapper22);
//        if(coefficientYear==null){
//            coefficientYear=new CoefficientYear();
//            coefficientYear.setCoefficient2(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//            coefficientYear.setCoefficient1(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//        }
//        //节煤炭量
//        map.put("a4",bigDecimal1.multiply(coefficientYear.getCoefficient1()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
//        //碳减排量
//        map.put("a5",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
//        map.put("a107",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000*18.3*40),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"


        if(n.getYear()==null){

            QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
            queryWrapper22.ge("year",2024);
            List<CoefficientYear> coefficientYears = coefficientYearMapper.selectList(queryWrapper22);
            bigDecimal1=new BigDecimal(0);
            BigDecimal bigDecimal2=new BigDecimal(0);
            for (int i = 0; i < coefficientYears.size(); i++) {
                CoefficientYear coefficientYear1 = coefficientYears.get(i);
                qxzxz = dataDayMapper.qxzxz31(n.getId(), 119,coefficientYear1.getYear(),n.getMonth());
                qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                qxzdz = dataDayMapper.qxzdz31(n.getId(),119,coefficientYear1.getYear(),n.getMonth());
                qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
                bigDecimal1 = bigDecimal1.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient1()));
                bigDecimal2 = bigDecimal2.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient2()));
            }


            //节煤炭量
            map.put("a4",bigDecimal1.divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //碳减排量
            map.put("a5",bigDecimal2.divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //植树
            map.put("a107",bigDecimal2.divide(new BigDecimal(1000*18.3*40),0, RoundingMode.UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

        }else {
            QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
            queryWrapper22.eq("year",n.getYear());
            CoefficientYear coefficientYear = coefficientYearMapper.selectOne(queryWrapper22);
            //节煤炭量
            map.put("a4",bigDecimal1.multiply(coefficientYear.getCoefficient1()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //碳减排量
            map.put("a5",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //植树
            map.put("a107",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*18.3*40),0, RoundingMode.HALF_UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

        }



        //系统效率
        OrganizationalStructure organizationalStructure = organizationalStructureMapper.selectById(n.getId());
        if (organizationalStructure==null || organizationalStructure.getInstalledKw5()==null || organizationalStructure.getInstalledKw5().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
            map.put("a2",new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        }else {
            if (organizationalStructure==null || organizationalStructure.getInstalledKw51()==null || organizationalStructure.getInstalledKw51().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<1){
                map.put("a2",new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }else {
                map.put("a2",(organizationalStructure.getInstalledKw51().divide(organizationalStructure.getInstalledKw5(),2).multiply(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }

        }
//        BigDecimal qxdqgl = dataDayMapper.qxdqgl(n.getId());
//        BigDecimal qxdqgl1 = dataDayMapper.qxdqgl1(n.getId());
//        if (qxdqgl1.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//            map.put("a2",0);
//        }else {
//            map.put("a2",qxdqgl.divide(qxdqgl1,2).multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP));
//        }

        long daysBetweenDates = DateTimeUtil.getDaysBetweenDates(organizationalStructure.getCreateTime(), new Date());
        map.put("a6",daysBetweenDates);//运行天数+"t"
        return map;
    }

    @Override
    public List<Map<String,Object>> nyzQuery3(NengKongDataDay n) {
        List<Map<String,Object>> list=new ArrayList<>();
        QueryWrapper<EquipmentManagement> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("site_id",n.getId());
        queryWrapper.eq("examine",1);
        List<EquipmentManagement> energyMacs = equipmentManagementMapper.selectList(queryWrapper);
        for (int i = 0; i < energyMacs.size(); i++) {
            EquipmentManagement equipmentManagement = energyMacs.get(i);
            BigDecimal newest=new BigDecimal(0);


            Map<String,Object> map=new HashMap<>();
            map.put("macId",equipmentManagement.getId());
            map.put("macName",equipmentManagement.getName());
            map.put("code",equipmentManagement.getSn());
            map.put("rateOfWork",equipmentManagement.getRateOfWork()==null?0:equipmentManagement.getRateOfWork().divide(new BigDecimal(1000),2).setScale(2, BigDecimal.ROUND_HALF_UP)+"kW");
//            map.put("temperature",equipmentManagement.getTemperature()==null?0:equipmentManagement.getTemperature().doubleValue()+"℃");
//            map.put("humidity",equipmentManagement.getHumidity()==null?0:equipmentManagement.getHumidity().doubleValue()+"%");
            if (equipmentManagement.getRateOfWorkDc()==null || equipmentManagement.getRateOfWorkDc().compareTo(new BigDecimal(0))!=1){
                map.put("efficiency",0+"%");
            }else {
                map.put("efficiency",equipmentManagement.getRateOfWork().multiply(new BigDecimal(100)).divide(equipmentManagement.getRateOfWorkDc(),2).setScale(2, BigDecimal.ROUND_HALF_UP)+"%");
            }

            map.put("operationState",(equipmentManagement.getOperationState()==null || equipmentManagement.getOperationState()!=0)?"停止":"运行");


            //110-温度
            n.setType(110);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            map.put("temperature",newest==null?0:newest.doubleValue()+"℃");
//            energyMac.setTemperature((newest==null?new BigDecimal(0):newest));//温度
//
//            //111-湿度
            n.setType(111);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            map.put("humidity",newest==null?0:newest.doubleValue()+"%");
//            energyMac.setTemperature(newest==null?new BigDecimal(0):newest);//湿度

            list.add(map);
        }
        return list;
    }

    @Override
    public Page<OpsTicketsMessage> gd(PageVo val) {
        //查找工单信息
        Page<OpsTicketsMessage> page = new Page<OpsTicketsMessage>(val.getPage(), val.getSize());
        QueryWrapper<OpsTicketsMessage> wrapper = new QueryWrapper<>();
//        wrapper.eq(ObjectUtils.isNotNull(val.getEnergyId()),"energy_id",val.getEnergyId());
        wrapper.eq(ObjectUtils.isNotNull(val.getState()),"state",val.getState());
        wrapper.like(ObjectUtils.isNotNull(val.getLike()),"name",val.getLike());
        wrapper.ge(ObjectUtils.isNotNull(val.getBeginTime()),"create_time",val.getBeginTime());
        wrapper.le(ObjectUtils.isNotNull(val.getOverTime()),"create_time",val.getOverTime());
        wrapper.orderByDesc("create_time");
        opsTicketsMessageMapper.selectPage(page, wrapper);

        return page;
    }

    @Override
    public List<OrganizationalStructure> wzxx() {
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("examine",1);
        queryWrapper.eq("type",6);
        List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(queryWrapper);
        return energyStations;
    }

    @Override
    public List<Map<String, Object>> jkdz(Long id) {
        List<Map<String, Object>> list=new ArrayList<>();
        QueryWrapper<VideoSurveillance> queryWrapper=new QueryWrapper<>();
        if (id==-1){
            queryWrapper.isNull("energy_id");
        }else {
            queryWrapper.eq("energy_id",id);
        }
        List<VideoSurveillance> videoSurveillances = videoSurveillanceMapper.selectList(queryWrapper);
        for (int i = 0; i <videoSurveillances.size(); i++) {
            Map<String, Object> map=new HashMap<>();
            VideoSurveillance videoSurveillance = videoSurveillances.get(i);
            map.put("accessToken",videoSurveillance.getAccessToken());
            map.put("img",videoSurveillance.getImg());
//            map.put("password",videoSurveillance.getPassword());
            Map<String, Object> m=new HashMap<>();
            m.put("accessToken",videoSurveillance.getAccessToken());
            m.put("deviceSerial",videoSurveillance.getDeviceSerial());
            m.put("channelNo",videoSurveillance.getChannelNo());
            m.put("code",videoSurveillance.getPassword());
            String url="https://open.ys7.com/api/lapp/v2/live/address/get";
            String s = doPostForm(url, m);
            if (s.equals("")){
                map.put("url",null);
            }else {
                JSONObject jsonObject = JSON.parseObject(s);
                if (jsonObject.getString("code").equals("200")){
                    String string = jsonObject.getJSONObject("data").getString("url");
                    map.put("url",string);
                }else {
                    map.put("url",null);
                    map.put("msg","萤石云返回错误："+jsonObject.getString("msg"));
                }
            }
            list.add(map);
        }
        return list;
    }

    @Override
    public List<EquipmentManagement> jkdz1(Long id) {
        //List<Object> list=new ArrayList<>();
        List<EquipmentManagement> equipment = new ArrayList<>();
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        //queryWrapper.isNotNull("jkdz");
        if (id!=null){
            queryWrapper.eq("id",id);
        }else {
            queryWrapper.eq("examine",1);
            queryWrapper.eq("type",6);
        }
        List<OrganizationalStructure> organizationalStructures = organizationalStructureMapper.selectList(queryWrapper);
        for (int i = 0; i < organizationalStructures.size(); i++) {
            OrganizationalStructure organizationalStructure = organizationalStructures.get(i);
            List<EquipmentManagement> equipmentManagements = equipmentManagementMapper.selectList(new QueryWrapper<EquipmentManagement>()
                    .eq("site_id", organizationalStructure.getId())
                    .eq("equipment_type",11).eq("examine",1).isNull("delete_examine"));
            if (!equipmentManagements.isEmpty()){
                for (EquipmentManagement equipmentManagement : equipmentManagements) {
                    equipment.add(equipmentManagement);
                }
            }
            //list.add(equipmentManagements);
            //list.add(organizationalStructure.getJkdz());
        }
        return  equipment;
    }

    @Override
    public Map<String, Object> nyzQueryXcx(NengKongDataDay n) {
        n.setEnergyId(n.getId());
        n.setTime(DateTimeUtil.dqsj());
        Map<String, Object> map=new HashMap<>();
        BigDecimal newest=new BigDecimal(0);
        //发电功率 107
        n.setType(107);
        n.setClassifyNumber(2);
        newest = dataDayMapper.qxdqgl(n.getId());//dataDayMapper.newest(n);
        newest =newest==null?new BigDecimal(0):newest.divide(new BigDecimal(1)).setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal fdgl=newest;
        map.put("a1",newest);//发电功率+"kw·h"

        OrganizationalStructure organizationalStructure = organizationalStructureMapper.selectById(n.getId());
        //装机
        newest=organizationalStructure.getInstalledCapacity();
        newest=newest==null?new BigDecimal(0):newest.divide(new BigDecimal(1)).setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal zj=newest;
        map.put("a3",newest);

        //系统效率
        if (zj.compareTo(new BigDecimal(0))==0){
            map.put("a2","0.00");
        }else {
            map.put("a2",fdgl.multiply(new BigDecimal(100)).divide(zj,2).setScale(2, BigDecimal.ROUND_HALF_UP));
        }
//        if (organizationalStructure==null || organizationalStructure.getInstalledKw5()==null || organizationalStructure.getInstalledKw5().compareTo(new BigDecimal(0))==0){
//            map.put("a2",0);
//        }else {
//            if (organizationalStructure==null || organizationalStructure.getInstalledKw51()==null || organizationalStructure.getInstalledKw51().compareTo(new BigDecimal(0))<1){
//                map.put("a2",0);
//            }else {
//                map.put("a2",organizationalStructure.getInstalledKw51().divide(organizationalStructure.getInstalledKw5(),2).multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP));
//            }
//
//        }

        //当日发电量
        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),119);
        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

        BigDecimal qxzdz = dataDayMapper.qxzdz1(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),119);
        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
        BigDecimal subtract = qxzdz.subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
        map.put("a4",subtract);

        //当月发电量
         qxzxz = dataDayMapper.qxzxz31(n.getId(), 119,DateTimeUtil.getYear(DateTimeUtil.dqsj()),DateTimeUtil.getMonth(DateTimeUtil.dqsj()));
        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

        qxzdz = dataDayMapper.qxzdz31(n.getId(), 119,DateTimeUtil.getYear(DateTimeUtil.dqsj()),DateTimeUtil.getMonth(DateTimeUtil.dqsj()));
        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
        subtract = qxzdz.subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
        map.put("a5",subtract);

        //累计发电量
        qxzxz = dataDayMapper.qxzxz31(n.getId(), 119,null,null);
        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

        qxzdz = dataDayMapper.qxzdz31(n.getId(),119, null,null);
        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
        subtract = qxzdz.subtract(qxzxz);
        subtract = subtract.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP);
        map.put("a6",subtract);


        QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
        queryWrapper22.ge("year",2024);
        List<CoefficientYear> coefficientYears = coefficientYearMapper.selectList(queryWrapper22);
        BigDecimal bigDecimal1=new BigDecimal(0);
        BigDecimal bigDecimal2=new BigDecimal(0);
        for (int i = 0; i < coefficientYears.size(); i++) {
            CoefficientYear coefficientYear1 = coefficientYears.get(i);
            qxzxz = dataDayMapper.qxzxz31(null, 119,coefficientYear1.getYear(),n.getMonth());
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            qxzdz = dataDayMapper.qxzdz31(null,119,coefficientYear1.getYear(),n.getMonth());
            qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
            bigDecimal1 = bigDecimal1.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient1()));
            bigDecimal2 = bigDecimal2.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient2()));
        }


        if(n.getYear()==null){
            QueryWrapper<CoefficientYear> queryWrapper221=new QueryWrapper<>();
            queryWrapper221.ge("year",2024);
            List<CoefficientYear> coefficientYears1 = coefficientYearMapper.selectList(queryWrapper221);
            bigDecimal1=new BigDecimal(0);
            BigDecimal bigDecimal21=new BigDecimal(0);
            for (int i = 0; i < coefficientYears1.size(); i++) {
                CoefficientYear coefficientYear1 = coefficientYears1.get(i);
                qxzxz = dataDayMapper.qxzxz31(n.getId(), 119,coefficientYear1.getYear(),n.getMonth());
                qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                qxzdz = dataDayMapper.qxzdz31(n.getId(),119,coefficientYear1.getYear(),n.getMonth());
                qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
                bigDecimal1 = bigDecimal1.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient1()));
                bigDecimal21 = bigDecimal21.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient2()));
            }


            //节煤炭量
            map.put("a8",bigDecimal1.divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //碳减排量
            map.put("a7",bigDecimal21.divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //植树
            map.put("a9",bigDecimal21.divide(new BigDecimal(1000*18.3*40),0, RoundingMode.UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

        }else {
            QueryWrapper<CoefficientYear> queryWrapper221=new QueryWrapper<>();
            queryWrapper221.eq("year",n.getYear());
            CoefficientYear coefficientYear = coefficientYearMapper.selectOne(queryWrapper221);
            //节煤炭量
            map.put("a8",bigDecimal1.multiply(coefficientYear.getCoefficient1()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //碳减排量
            map.put("a7",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //植树
            map.put("a9",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*18.3*40),0, RoundingMode.HALF_UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

        }


//
//        //节煤炭量
//        map.put("a8",bigDecimal1.divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
//        //碳减排量
//        map.put("a7",bigDecimal2.divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
//        //植树
//        map.put("a9",bigDecimal2.divide(new BigDecimal(1000*18.3*40),0, RoundingMode.UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"
        return map;
    }


    @Override
    public Map<String, Object> nyzQueryXcx11(NengKongDataDay n) {
        n.setEnergyId(n.getId());
        n.setTime(DateTimeUtil.dqsj());
        Map<String, Object> map=new HashMap<>();
        BigDecimal newest=new BigDecimal(0);

        //当日发电量
        BigDecimal qxzxz = dataDayMapper.qxzxz122(n.getId(),n.getMacId(), DateTimeUtil.getStrDateTime3(n.getTime()),119);
        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

        BigDecimal qxzdz = dataDayMapper.qxzdz122(n.getId(),n.getMacId(), DateTimeUtil.getStrDateTime3(n.getTime()),119);
        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
        BigDecimal subtract = qxzdz.subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
        map.put("a1",subtract);

        //当月发电量
        qxzxz = dataDayMapper.qxzxz3122(n.getId(),n.getMacId(), 119,DateTimeUtil.getYear(DateTimeUtil.dqsj()),DateTimeUtil.getMonth(DateTimeUtil.dqsj()));
        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

        qxzdz = dataDayMapper.qxzdz3122(n.getId(),n.getMacId(), 119,DateTimeUtil.getYear(DateTimeUtil.dqsj()),DateTimeUtil.getMonth(DateTimeUtil.dqsj()));
        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
        subtract = qxzdz.subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
        map.put("a2",subtract);

        //当年发电量
        qxzxz = dataDayMapper.qxzxz322(n.getId(),n.getMacId(), 119,DateTimeUtil.getYear(DateTimeUtil.dqsj()));
        qxzxz=qxzxz==null?new BigDecimal(0):qxzxz;

        qxzdz = dataDayMapper.qxzdz322(n.getId(),n.getMacId(),119, DateTimeUtil.getYear(DateTimeUtil.dqsj()));
        qxzdz=qxzdz==null?new BigDecimal(0):qxzdz;
        subtract = qxzdz.subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
        map.put("a3",subtract);

        EquipmentManagement equipmentManagement = equipmentManagementMapper.selectById(n.getMacId());
        map.put("a4",equipmentManagement.getRateOfWork());
        return map;
    }

    @Override
    public Map<String, Object> cxlj(IndexGfVo indexGfVo) {
        int year = DateTimeUtil.getYear();
        int month = DateTimeUtil.getMonth();
        int day = DateTimeUtil.getDay();
        if (indexGfVo.getType()==1){
            String s = year + "-" + month +"-" + day;
            indexGfVo.setStartTime(s+" 00:00:00");
            indexGfVo.setEndTime(s+" 23:59:59");
        }else if (indexGfVo.getType()==2){
            String s1 = year + "-" + month + "-01";

            String s2 = year + "-" + (month+1) + "-01";
            if (month==12){
                s2 = year+1 + "-" + "01" + "-01";
            }
            indexGfVo.setStartTime(s1+" 00:00:00");
            indexGfVo.setEndTime(s2+" 00:00:00");
        } else if (indexGfVo.getType()==3) {
            String s1 = year + "-" + "01" + "-01";

            String s2 = year+1 + "-" + "01" + "-01";
            indexGfVo.setStartTime(s1+" 00:00:00");
            indexGfVo.setEndTime(s2+" 00:00:00");
        }else {

        }
        indexGfVo.setType(119);
        BigDecimal bigDecimal1 = dataDayMapper.cxcz1(indexGfVo);
        indexGfVo.setType(116);
        BigDecimal bigDecimal2 = dataDayMapper.cxcz1(indexGfVo);
        indexGfVo.setType(115);
        BigDecimal bigDecimal3 = dataDayMapper.cxcz1(indexGfVo);
        Map<String, Object> map=new HashMap<>();
        map.put("a1",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("a2",bigDecimal2.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("a3",bigDecimal3.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        return map;
    }

    /**
     * form表单提交
     * @param url
     * @param map
     * @return
     */
    public static String doPostForm(String url, Map<String, Object> map) {
        String strResult = "";
        // 1. 获取默认的client实例
        CloseableHttpClient client = HttpClients.createDefault();
        // 2. 创建httppost实例
        HttpPost httpPost = new HttpPost(url);
        httpPost.setHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
        // 3. 创建参数队列（键值对列表）
        List<NameValuePair> paramPairs = new ArrayList<>();
        Set<String> keySet = map.keySet();
        for (String key : keySet) {
            Object val = map.get(key);
            paramPairs.add(new BasicNameValuePair(key, val.toString()));
        }
        UrlEncodedFormEntity entity;
        try {
            // 4. 将参数设置到entity对象中
            entity = new UrlEncodedFormEntity(paramPairs, "UTF-8");
            System.out.println("封装的参数："+entity);
            // 5. 将entity对象设置到httppost对象中
            httpPost.setEntity(entity);
            // 6. 发送请求并回去响应
            CloseableHttpResponse resp = client.execute(httpPost);
            try {
                // 7. 获取响应entity
                HttpEntity respEntity = resp.getEntity();
                strResult = EntityUtils.toString(respEntity, "UTF-8");
            } finally {
                // 9. 关闭响应对象
                resp.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 10. 关闭连接，释放资源
            try {
                client.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return strResult;
    }
}
